package com.hk;

import com.alibaba.fastjson.JSON;
import com.hk.domain.dto.Student22;
import com.hk.domain.entity.Child;
import com.hk.domain.entity.Student;
import com.hk.service.profile.impl.DevMessage;
import com.hk.utils.DateStyle;
import com.hk.utils.LocalDateUtils;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.util.CollectionUtils;
import red.zyc.desensitization.Sensitive;

import java.lang.reflect.Method;
import java.text.DecimalFormat;
import java.util.*;

/**
 * @author: dpb
 * @Description TODO
 * @date: 2023/2/8 16:05
 * @Version 1.0
 *
 */
@Slf4j
public class Demo {
    public static void main(String[] args) {
//        String json = "{\n" +
//                "\"abstract\":\"zs\",\n" +
//                "\"pwd\":\"123\"\n" +
//                "}";
//
//        Student22 student22 = JSON.parseObject(json, Student22.class);
//        System.out.println(student22);
//
//        String stuString = JSON.toJSONString(student22);
//        stuString = stuString.replace("username", "abstract");
//        System.out.println(stuString);
//
//        Method[] methods = DevMessage.class.getMethods();
//        for (Method method : methods) {
//            //public返回1
//            int modifiers = method.getModifiers();
//            System.out.println("modifiers:" + modifiers);
//        }

//        long start = Long.valueOf("2020" + "-01-01 00:00:00");
        Date date = LocalDateUtils.formatDate("2020" + "-01-01 00:00:00", DateStyle.YYYY_MM_DD_HH_MM_SS);
        long time = date.getTime();
        long end = time - 1;
        System.out.println(time);
        System.out.println(end);
//        long end = Long.valueOf("2020" + "-12-31 00:00:00");
//        System.out.println(start);
//        System.out.println(end);

        Student student = new Student();
        student.setAge("23");
        student.setName("zs");

        Student student2 = new Student();
        student2.setAge("23");
        student2.setName("ls");

//        List<Student22> student22 = EntityUtils.toList(Arrays.asList(student, student2), Student22::new);
//        System.out.println(student22);

        Set<String> set = null;
        if (CollectionUtils.isEmpty(set)) {
            log.info("set is empty");
        }


//        Child child = new Child();
//        System.out.println(child);
//
//        Child desensitizeChild = Sensitive.desensitize(child);
//        System.out.println(desensitizeChild);



        Double doule = 2.0;
        String s = String.valueOf(doule);
        System.out.println(s);
        boolean result = s.endsWith(".0");
        if (result) {
            String replace = s.replace(".0", "");
            Double aDouble = Double.valueOf(replace);
            System.out.println(aDouble);
        }


//        JSONObject fromObject = JSONObject.fromObject("{\"productId\":\"1\",\"name\":\"zs\",\"age\":1}");

        com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject("{\"productId\":\"1\",\"name\":\"zs\",\"age\":1}");
//        Object productId = fromObject.get("productId");
        System.out.println(jsonObject.get("productId"));
//        System.out.println(productId);


        Double ratio = Double.valueOf(String.valueOf(1.2333));
        //保留2位小数
        String ratioFormat = new DecimalFormat("#.##").format(ratio);
        System.out.println(ratioFormat);


    }
}
